package com.lagou.homework.Modules1;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class SortReducer extends Reducer<LongWritable, NullWritable, LongWritable, LongWritable> {

    //排序初始化
    long index = 0;

    @Override
    protected void reduce(LongWritable key, Iterable<NullWritable> values, Context context) throws IOException, InterruptedException {

        LongWritable k = new LongWritable();

        for (NullWritable value : values) {
            index++;
            //数据
            k.set(index);
            context.write(k, key);
        }

    }
}

